<!DOCTYPE html>
<html>

	<head lang="en">
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
		<link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.2/style/weui.min.css">
		<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.min.css">
		<link rel="stylesheet" href="css/reset.css" />
		<link rel="stylesheet" href="css/global.css" />
	</head>

	<body style="background-color: #f4f4f4;">
		<div class="writeHead">
			<div class="writeHead_top center">
				<a href="index.html"><img src="img/backIcon.png" alt="" class="backBtn" /></a>
				<h1>帖子内容</h1>
			</div>
		</div>
		<div style="width: 100%;height: 46px"></div>
		<div class="lt_contentTop">
			<h1 class="lt_contentTop_Title"></h1>
			<div class="lt_contentTop_Msg">
				<!--<a href="">-->
					<div class="ltConPic"><img src="img/cs.png" alt="" /></div>
					<p>坦诚相待</p>
				<!--</a>-->
				<!--<button class="ltCon_collect">收藏</button>-->
			</div>
			<div class="ltCon_detail">
				<p></p>
			</div>
		</div>
		<div class="ltCon_pend">
			<!--<p class="ltCon_pendFont center">评论区</p>
			<div class="ltCon_pendCen center">
				<div class="ltCon_pendCen_left">
					<a href=""><img src="img/cs.png" alt="" /></a>
				</div>
				<div class="ltCon_pendCen_right">
					<a href=""><h6>坦诚相待</h6></a>
					<span>8分钟前</span>
					<div class="clear"></div>
					<p class="ltReplay">那价格还是很低啊，知道怎么改竞价吗？</p>
					<div class="ltDo"><span>回复</span></div>
				</div>
			</div>	-->	
		</div>
		<div style="width: 100%;height: 50px"></div>
		<div class="ltConFoot">
			<div class="ltConFoot_cen center">
				<input type="text" placeholder="说说看法" id="content"/>
				<input type="submit" value="" id="submit"/>
			</div>
		</div>
	</body>

</html>
<script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.min.js"></script>
<script>
	$(function() {
		
		var url = location.search; //获取url中"?"符后的字串 ('?modFlag=business&role=1')  
		var recId = url.substring(url.indexOf("=")+1,url.length);
		//alert(recId);
		//var theRequest = new Object();  
		/*if ( url.indexOf( "?" ) != -1 ) {  
		  var str = url.substr( 1 ); //substr()方法返回从参数值开始到结束的字符串；  
		  var strs = str.split( "&" );  
		  for ( var i = 0; i < strs.length; i++ ) {  
		    theRequest[ strs[ i ].split( "=" )[ 0 ] ] = ( strs[ i ].split( "=" )[ 1 ] );  
		  }  
		  console.log( theRequest );
		}*/
		
		$.when(
			$.ajax({
				type: "get",
				url:  "http://192.168.0.100:8080/recruitment/getById"+url,
				dataType: "json",
			})
		).done(function(data) {
			//alert(data.jobTitle);
			$(".lt_contentTop_Title").text(data.data.jobTitle);
			$(".ltCon_detail").html(data.data.html);
			
			console.log(data)
		}).fail(function(data){
			console.log(data.statusText);
		})	
		
		setPend(recId);
		
		var box = document.getElementById('submit');
		box.addEventListener('touchstart', function(ev) {	
				var content = $("#content").val();
				if(content==null || content==""){					
					return false;
				}
				$.when(
					$.ajax({
						type: "post",
						url:  "http://192.168.0.100:8080/commentProtal/create",
						data:{"content":content,"recId":recId},
						dataType: "json",
					})
				).done(function(data) {
					if(data.code == "SUCCESS"){
						$("#content").val("");
						setPend(recId);
					}
					console.log(data)
				}).fail(function(data){
					alert("ss");
					console.log(data.statusText);
				})	
		}, false)
	});
	
	function setPend(recId){
		$.when(
			$.ajax({
				type: "get",
				url:  "http://192.168.0.100:8080/commentProtal/getGrid?recId="+recId,
				dataType: "json",
			})
		).done(function(data) {
			var html="";
			$.each(data,function(i,r){
				html=html+"<div class='ltCon_pendCen center'><div class='ltCon_pendCen_left'><img src='img/cs.png' alt='' /></div><div class='ltCon_pendCen_right'><h6>匿名用户</h6><span>评论时间:"+r.createDateTime+"</span><div class='clear'></div><p class='ltReplay'>"+r.content+"</p></div></div>";
			//	alert(html);
				});
			console.log(html);
			var p = "";
			if(data.length<1){
				p = "<p class='ltCon_pendFont center'>暂无评论</p>";
			}else{
				p = "<p class='ltCon_pendFont center'>评论区</p>";
			}
			$(".ltCon_pend").empty().append(p).append(html);
		}).fail(function(data){
			console.log(data.statusText);
		})
	}
</script>